import { Body, Controller, Get, Param, Post } from '@nestjs/common';
import { ApiBearerAuth, ApiOperation, ApiTags } from '@nestjs/swagger';
import { ArticleService } from './article.service';
import { CreateArticleDto } from './article.dto';

@ApiTags('文章模块')
@ApiBearerAuth()
@Controller('article')
export class ArticleController {
  constructor(private articleService: ArticleService) {}

  @Post('create')
  @ApiOperation({ summary: '发布文章' })
  async createArticle(@Body() data: CreateArticleDto) {
    return await this.articleService.create(data);
  }

  @Get('list')
  @ApiOperation({ summary: '获取文章列表' })
  async getArticleList() {
    return this.articleService.find();
  }

  @Get('detail/:id')
  @ApiOperation({ summary: '获取文章详细' })
  async getArticleDetail(@Param('id') id: string) {
    return await this.articleService.findOne(+id);
  }
}
